// ==UserScript==
// @name file
// @author wgu
// @description  file
// @include file:///D:/pic.html
// ==/UserScript==
gw.import('pag/yzm2.js',window);
(function($,jQuery){	

	var path='D:\\cc'
		,names=gw.getFile(path).split(','),j=0
		,yzm=new $.yzm($('img')[0],4,{w:87,h:31})
		,db=gw.db('yzm.sqlite').open()
		;

	$.yzm.prototype.get=function(tmp){
		var ary=tmp.tz.point,str='',code=names[j][tmp.i];
		for(var i in ary){
			str+=ary[i].join('');
		}
		
		var re=db.getData("select code,n from ccbyzm where tz='"+str+"'",[0,1]);
		if(re.length==0){
			db.exeSQL("INSERT INTO ccbyzm  VALUES ('"+str+"','"+code+"',1)");
		}else if(re.length==1&&re[0][0]==code){
			db.exeSQL("UPDATE  ccbyzm  set n="+(re[0][1]+1)+" where tz='"+str+"'");
		}else{
			db.exeSQL("UPDATE  ccbyzm  set n=999 where tz='"+str+"'");
		}
		console.log('------------------------------------------------');
		return '';
		/*
		x=[tmp.showX(),tmp.showY(),tmp.showX2(),tmp.showY2()];
		console.log('------------------------------------------------');
		console.log("'"+tmp.showX()+"':{\n\t'"+tmp.showY()+"':{\n\t\t'"+tmp.showX2()+"':{\n\t\t\t'"+tmp.showY2()+"':@@\n\t\t}\n\t}\n},");
		if(code[x.join('@')]){
			return code[x.join('@')];
		}else{
			return "*";
			//throw "erro";
			//return;
		}*/
	}
	
	
	$('img')[0].onload=function(){
		yzm.load(1,1)
			//.removePt()
			.removeBG().cut(10,15);
		j++;
		
		var obj=this;
		setTimeout(function(){
			obj.src='file:///D:/cc/'+names[j];
		},100)
		
	}
	

	
	$('<button>click</button>').appendTo('body')
								.click(function(){
									//$('img')[0].src='file:///D:/bb/cc/1001.png';
									$('img')[0].src='file:///D:/cc/'+names[j];
								});
	
	
})(___jQuery,___jQuery)